LGF_TimerSwitch (FB / 3.1.0)

Overview

Author: Siemens Digital Industry

Short description

This block is a timer. It is possible to define daily, weekly, monthly, yearly time switch points and time switch points for working days or weekend days.
Mode: Permanently off: 0, Daily: 1, Weekly: 2, Monthly: 3, Yearly: 4, Workday: 5, Weekend: 6, Permanently on: 10

The time value is always compared with the local time of the PLC, therefore the time value specified at the On and Off parameters must be specified as local time.

Block Interface

LGF_TimerSwitch (FB)
USInt  onMonth signal  Bool
    
USInt  onDay actLocalTime  DTL
    
USInt  onWeekday error  Bool
    
USInt  onHour status  Word
    
USInt  onMinute subFunctionStatus  Word
    
USInt  offMonth   
    
USInt  offDay   
    
USInt  offWeekday   
    
USInt  offHour   
    
USInt  offMinute   
    
USInt  mode   
    
   

Input parameter

IdentifierData type Default value Description
onMonthUSInt 0 Month, in which the signal shall be set.
onDayUSInt 0 Day, at which the signal shall be set.
onWeekdayUSInt 0 Day of the week on which the signal will be set;
Sunday: 1, Monday: 2, Tuesday: 3, ...
onHourUSInt 0 Hour, at which the signal shall be set.
onMinuteUSInt 0 Minute, at which the signal shall be set.
offMonthUSInt 0 Month, in which the signal shall be reset.
offDayUSInt 0 Day, at which the signal shall be reset.
offWeekdayUSInt 0 Day of the week on which the signal will be reset;
Sunday: 1, Monday: 2, Tuesday: 3, ...
offHourUSInt 0 Hour, at which the signal shall be reset.
offMinuteUSInt 0 Minute, at which the signal shall be reset.
modeUSInt 0 Specifies the mode (see Principle of operation);
Permanently off: 0, Daily: 1, Weekly: 2, Monthly: 3, Yearly: 4, Workday: 5, Weekend: 6, Permanently on: 10

Output parameter

IdentifierData type Description
signalBool Output signal
actLocalTimeDTL Current local time
errorBool FALSE: No error / TRUE: An error occurred during the execution of the FB
statusWord 16#0000-16#7FFF: Status of the FB / 16#8000-16#FFFF: Error identification (see following Table)
subFunctionStatusWord Sub function status code

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_NO_ERROR
Status: no error occurred
16#8200ERR_NO_MODE_SELECTED
Error: No suitable mode is selected, check input "mode"
16#8600ERR_RD_LOC_T
Error in function RD_LOC_T, see in `subFunctionStatus`

Functional description

NOTE
The status of called commands is output in subFunctionStatus. In this case, the output value in status indicates which command caused the error. In this case, refer to the TIA Portal Online Help section for information on the respective commands.

NOTE
The function uses internally the system function RD_LOC_T to read the local time of the CPU, for the correct function it is therefore necessary that the local time of the CPU is set correctly.

The block offers various timer types, which are determined in the mode parameter:

The time value is always compared with the local time of the PLC, therefore the time value specified at the On and Off parameters must be specified as local time.

Depending on the mode, the following formal parameters must be interconnected:

Mode Mode Required formal parameters
0 . Permanently OFF
  • none
1 . Daily timer
  • onHour / offHour
  • onMinute / offMinute
2 . Weekly timer
  • onWeekday / offWeekday
  • onHour / offHour
  • onMinute / offMinute
3 . Monthly timer
  • onDay / offDay
  • onHour / offHour
  • onMinute / offMinute
4 . Yearly timer
  • onMonth / offMonth
  • onDay / offDay
  • onHour / offHour
  • onMinute / offMinute
5 . Weekdays
  • onHour / offHour
  • onMinute / offMinute
6 . Weekend
  • onHour / offHour
  • onMinute / offMinute
10 . Permanently ON
  • none

If the set start time equals the current local time of the controller, the output signal is set to TRUE. If the set switch-off time equals the current local time of the controller, the signal output is reset again.


NOTE
Please note that the block can be used in the “Monthly timer” modes (mode = 3) or “yearly timer” (mode = 4) the block only switches if the days that you specify at the input parameters, “onDay” and “offDay”, actually occur in this month.

Change log

Version & DateChange description
1.0.0Siemens Industry Online Support
19.08.2015First released version
1.0.1Siemens Industry Online Support
16.11.2015Fix in mode 2
1.1.0Siemens Industry Online Support
23.05.2016New mode 5 + 6
New output: actLocalTime
1.1.1Siemens Industry Online Support
02.01.2017Upgrade: TIA V14 Update 1
1.1.2Siemens Industry Online Support
14.09.2018Fix in modes 1, 3, 5, 6
1.1.3Siemens Industry Online Support
17.09.2018Upgrade: TIA V15 Update 2
1.1.4Siemens Industry Online Support
10.10.2018Connection to type restored
1.1.5Siemens Industry Online Support
23.11.2018Upgrade: TIA V15.1
1.1.10Simatic Systems Support
13.11.2019Magic numbers removed, tag naming added, code reworked
3.0.0Simatic Systems Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
3.0.1Simatic Systems Support
19.01.2020Insert documentation
3.1.0Simatic Systems Support
03.06.2022Insert mode `permanently On`: `10`, `permanently Off`: `0`